/*
 * Copyright (C) 2012 mAPPn.Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mol.market.demo.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;


/**
 * 第三层Activity，按Back将会返回{@link SecondFragmentActivity}
 *
 * @author Chaos
 * @Description 跳转到这个Activity的入口 (分发至Fragment显示) 如下：
 * <br>
 * 游戏-精选标签-点击任意标签  --> {@link TagsListFragment}
 * <br>
 * 应用-精选标签-点击任意标签  --> {@link TagsListFragment}
 * @date 2013-1-23
 */
public class ThirdFragmentActivity extends SecondFragmentActivity {

    @Override
    protected Fragment distribute(String tag) {

        Fragment result = null;
        Bundle args = new Bundle();

        if (KeyStore.TARGET_CATEGORY_TAG_LIST.equals(tag)) {

            if (getIntent() != null) {
                args.putString(KeyStore.KEY_ARG, getIntent().getStringExtra(KeyStore.KEY_ARG));
            }
            result = Fragment.instantiate(getApplicationContext(),
                    TagsListFragment.class.getName(), args);
        }

        return result == null ? super.distribute(tag) : result;
    }

    @Override
    protected void setActionBarText(String tag) {
        if (getIntent() != null) {
            getSupportActionBar().setTitle(getIntent().getStringExtra(KeyStore.KEY_TITLE));
        } else {
            super.setActionBarText(tag);
        }
    }

}
